#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
int main_65()
{
    int n,a,b,idx,val,temp;
    scanf("%d%d%d",&n,&a,&b);
    LL ans=0;
    unordered_map<int,int> sparse_vector;
    for (int i=0;i<a ;++i )
    {
        scanf("%d%d",&idx,&val);
        sparse_vector[idx]=val;
    }
    for (int i=0;i<b ;++i )
    {
        scanf("%d%d",&idx,&val);
        temp=sparse_vector[idx];
        if (temp!=0)
        {
            ans+=val*temp;
        }
    }
    printf("%lld",ans);
    return 0;
}
